<?php
declare (strict_types = 1);
namespace app\user\logic\teacher;

use app\common\exception\LogicException;
use app\user\model\teacher\TeacherLog as TeacherLogModel;

/**
 * 讲师记录逻辑层
 */
class TeacherLog extends TeacherLogModel
{

    /**
     * 生成日志
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-06-19
     * @param  int                         $mhm_id  [description]
     * @param  string                      $info    [description]
     * @param  int|integer                 $user_id [description]
     * @return [type]                               [description]
     */
    public function writeLog(int $mhm_id, string $info, int $user_id = 0)
    {
        $this->mhm_id  = $mhm_id;
        $this->info    = $info;
        $this->user_id = $user_id;

        if (!$this->save()) throw new LogicException('日志生成失败');

        return $this;
    }
}
